// 列表请求公用方法
import {
	getList
} from '@/api/crud.js'

export default {
	data() {
		return {
			pageNum: 0,
			totalNum: 0,
			pageSizeNum: 10
		}
	},
	methods: {
		async getData(name, formData, pageNumber) {
			const form = formData || this.form;
			let data = form ? JSON.parse(JSON.stringify(form)) : {};
			const loginForm = this.$store.getters.loginForm;
			try {
				return await getList({
					...data,
					uid: loginForm && loginForm.uid,
					page: pageNumber || this.pageNum,
					size: this.pageSizeNum
				}, this.apiType, this.apiModule, name)
			} catch (error) {
				console.log(error)
				return Promise.reject()
			}
		},
		// 获取列表完成后赋值
		successList({
			data
		}) {
			this.data = data.content
		}
	}
}
